/**
 * This file is part of 1genia trampoline
 * Copyright (C) 2007 1genia (contact@1genia.com)
 *
 * This library is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; version 3 of the License. 
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details. 
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; see the file COPYING.TXT.  If not,
 * write to the Free Software Foundation, Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301, USA. 
 **/
package com.genia.toolbox.form.editor;

import java.io.File;
import java.rmi.server.UID;
import java.util.List;

import com.genia.toolbox.basics.editor.AbstractController;
import com.genia.toolbox.form.editor.gui.FormEditorGUI;
import com.genia.toolbox.form.editor.model.bean.FormInitialSettings;
import com.genia.toolbox.form.editor.model.document.impl.DocumentModel;
import com.genia.toolbox.form.editor.model.form.impl.FormModel;
import com.genia.toolbox.web.gwt.form.client.form.Form;
import com.genia.toolbox.web.gwt.form.server.description.item.ItemDescription;
import com.genia.toolbox.web.gwt.form.server.description.validator.ValidatorDescription;
import com.genia.toolbox.web.portlet.description.ContainerPortletDescription.LayoutDirection;

/**
 * The form editor controller.
 */
public class FormEditorController
    extends AbstractController<FormEditorApplication, FormEditorGUI, DocumentModel, FormModel, FormInitialSettings>
{

  /**
   * Constructor.
   * 
   * @param application
   *          The application.
   * @param gui
   *          The gui.
   */
  public FormEditorController(FormEditorApplication application, FormEditorGUI gui)
  {
    super(application, gui);
  }



  /**
   * Return the list of item descriptions.
   * 
   * @return the list of item descriptions.
   */
  public List<ItemDescription> notifyDisplayItemDescriptions()
  {
    return this.getApplication().getItemDescriptions();
  }



  /**
   * Return the list of validator descriptions.
   * 
   * @return the list of validator descriptions.
   */
  public List<ValidatorDescription> notifyDisplayValidatorDescriptions()
  {
    return this.getApplication().getValidatorDescriptions();
  }



  /**
   * Notify a tab element creation.
   * 
   * @param settings
   *          the tab element initial settings.
   * @param documentUniqueID
   *          the document unique ID.
   * @param parentUniqueID
   *          the parent element unique ID.
   * @param direction
   *          the layout direction.
   */
  public void notifyCreateTab(FormInitialSettings settings, UID documentUniqueID, UID parentUniqueID, LayoutDirection direction)
  {
    this.getApplication().createNewTab(settings, documentUniqueID, parentUniqueID, direction);
  }



  /**
   * Notify a backup jsp file selection.
   * 
   * @return The file.
   */

  public File notifySelectABackupJspFile()
  {
    return this.getGUI().saveJspFile();
  }
  
  /**
   * Notify a backup jsp file selection.
   * 
   * @return The file.
   */

  public File notifySelectABackupJspFolder()
  {
    return this.getGUI().saveJspFolder();
  }



  /**
   * Return the existing forms.
   * 
   * @return the existing forms.
   */
  public List<Form> notifyDisplayForms()
  {
    return this.getApplication().getForms();
  }



  /**
   * Notify a form generation.
   * 
   * @param form
   *          the form to export.
   */
  public void notifyExportToJsp(Form form)
  {
    this.getApplication().exportDocumentToJsp(form);
  }
  
  /**
   * Notify a form bench generation.
   * 
   * @param forms
   *          the forms to export.
   */
  public void notifyExportAllToJsp(List<Form> forms)
  {
    this.getApplication().exportDocumentsToJsp(forms);
  }

}
